import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2021/11/26
 * \* Time: 19:26
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class TestDemo2 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>(20);
        //学习时看源码——构造方法
        ArrayList<String> list2=new ArrayList<>();
        list2.add("hello");
        list2.add("zhujian");
        System.out.println(list2);
        System.out.println("==============");
        for(int i=0;i<list2.size();i++){
            System.out.print(list2.get(i));

            System.out.println("============");
            for(String s : list2)
             System.out.print(s+" ");
            System.out.println("============");
            Iterator <String> it=list2.iterator();
            while ((it.hasNext())){
                System.out.print(it.next()+" ");

                System.out.println();
                ListIterator<String> it2=list2.listIterator();
                while (it2.hasNext()){
                    System.out.print(it2.next()+" ");
                }
            }
        }
    }
    public static void main1(String[] args) {
        List<String> list=new ArrayList<>(20);
        //学习时看源码——构造方法
        ArrayList<String> list2=new ArrayList<>();
        list2.add("hello");
        list2.add("zhujian");
        System.out.println(list2);
        //使用另外一个ArratList3进行初始化
        ArrayList<String> list3=new ArrayList<>(list2);
    }
}
